package interlocking.model;

public class Train {
    private int x; // 列车当前位置x坐标
    private int y; // 列车当前位置y坐标
    private int speed; // 列车速度(像素/帧)
    private int length;
    private Route route; // 列车行进路线

    public Train(int x,int y,int speed,int length){
        this.x=x;
        this.y=y;
        this.speed=speed;
        this.length=length;
    }
    public void move() {   //路线1的运动方向
        if(this.x<200){
            this.x+=speed;

        }
        if(this.x>=200&&this.y>250&&this.x<250){
            this.x+=speed;
            this.y-=speed;
        }
        if(this.y==250){
            this.x+=speed;
        }
        if(this.x>=450&&this.y<300&&this.x<500){
            this.x+=speed;
            this.y+=speed;
        }
        if(this.x>=500&&this.y==300&&this.x<=650){
            this.x+=speed;
        }
        if(this.x==650&&this.y==300){
            this.x=700;
            this.y=301;
        }
    }

    public void move2(){
        if(this.x<=700){
            this.x+=speed;
        }
    }

    public void move3(){
        if(this.x<250){
            this.x+=speed;

        }
        if(this.x>=250&&this.y<350&&this.x<300){
            this.x+=speed;
            this.y+=speed;
        }
        if(this.y==350){
            this.x+=speed;
        }
        if(this.x>=500&&this.y>300&&this.x<550){
            this.x+=speed;
            this.y-=speed;
        }
        if(this.x>=550&&this.y==300&&this.x<=650){
            this.x+=speed;
        }
        if(this.x==650&&this.y==300){
            this.x=700;
            this.y=301;
        }
    }

    public int getX() {
        return x;
    }

    public int getY() {
        return y;
    }

    public int getSpeed() {
        return speed;
    }

    public int getLength() {
        return length;
    }
}
